from pydantic_settings import BaseSettings
from functools import lru_cache

class settings(BaseSettings):
    DATABASE: str = "mysql"
    DEBUG: bool = True
    HOST: str = "localhost"
    SCHEMA: str = "mydatabase"
    USER: str = "root"
    PASSWORD: str = "root"
    SECRET_KEY: str = "xxx"
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
    PORT: int = 3306
    REFRESH_TOKEN_EXPIRE_MINUTES: int
    ALLOWED_EXTENSIONS: set
    class Config:
        env_file = ("../.env")

@lru_cache  # 使用缓存机制，避免多次读取环境变量
def get_settings():
    config = settings()
    return config

config = get_settings()
